package queue;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConnUtil {
    public static Connection getConn() throws IOException, TimeoutException {
        // 建立连接
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.10.128");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("rabbitadmin");
        connectionFactory.setPassword("123456");
        connectionFactory.setVirtualHost("test");

        // 创建连接
        return connectionFactory.newConnection();

    }
}
